package weeny.kdtree;

import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

public class kdTreeUtilTest extends TestCase{

	public void testDuplicate(){
		KdTreeUtil util = new KdTreeUtil(){
			protected double[] toArray(Object obj) {
				return new double[]{(Integer) obj};
			}
		};
		List list = new ArrayList();
		list.add(1);list.add(2);list.add(3);list.add(1);
		util.addCollection(list, true);
		List result = util.nearestList(1);
		assertEquals(result.size(), 2);
		result = util.nearestList(2);
		assertEquals(result.size(), 1);
		result = util.nearestList(1,2);
		assertEquals(result.size(), 2);
		assertEquals(((List) result.get(0)).get(0), 1);
		assertEquals(((List) result.get(0)).get(1), 1);
		assertEquals(((List) result.get(1)).size(), 1);
		assertEquals(((List) result.get(1)).get(0), 2);
	}
	public void testTest(){
		assertEquals(true, true);
	}
}
